﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.crew.ui {
    import flash.events.*;
    import flash.geom.*;
    import Engine.Helpers.*;
    import Classes.*;
    import Display.FactoryUI.*;
    import Engine.*;

    public class NPCSlidePick extends SlidePick {

        protected const PICK_OFFSET:Point;

        protected var m_npc:NPC = null;
        protected var m_position:Vector3;
        protected var m_onAccept:Function;
        protected var m_listeningToRender:Boolean = false;

        public function NPCSlidePick(_arg1:NPC, _arg2:String, _arg3:Function){
            this.PICK_OFFSET = new Point(-30, -70);
            super(_arg2, false, false);
            this.m_npc = _arg1;
            this.m_onAccept = _arg3;
            addEventListener(MouseEvent.MOUSE_DOWN, this.onClick, false, 0, true);
        }
        protected function onClick(_arg1:MouseEvent):void{
            if (Global.ui.mouseEnabled == false){
                return;
            };
            this.m_onAccept();
        }
        override protected function getPickBackground():Class{
            return (EmbeddedArt.trainUIPick);
        }
        override protected function getInnerBackground():Class{
            return (EmbeddedArt.friendReplaySlide);
        }
        override public function setPosition(_arg1:Number, _arg2:Number):void{
            this.m_position = new Vector3((_arg1 + 3), (_arg2 + 3));
            this.startListen();
        }
        protected function startListen():void{
            if (((!(this.m_listeningToRender)) && (!((stage == null))))){
                stage.addEventListener(Event.RENDER, this.renderListener, false, 0, true);
                this.m_listeningToRender = true;
            };
        }
        override public function kill(_arg1:Function=null):void{
            super.kill(_arg1);
            if (this.m_listeningToRender){
                Global.stage.removeEventListener(Event.RENDER, this.renderListener);
                this.m_listeningToRender = false;
            };
            removeEventListener(MouseEvent.MOUSE_DOWN, this.onClick, false);
        }
        protected function renderListener(_arg1:Event):void{
            var _local2:Point;
            if (this.m_position){
                _local2 = IsoMath.tilePosToPixelPos(this.m_position.x, this.m_position.y);
                _local2 = IsoMath.viewportToStage(_local2);
                this.x = (_local2.x + this.PICK_OFFSET.x);
                this.y = (_local2.y + this.PICK_OFFSET.y);
            };
        }

    }
}//package Modules.crew.ui 
